<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<link rel="stylesheet"  href="/layui/css/layui.css"/>
<meta charset="UTF-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>修改健康资讯</title>
</head>
<body>
<script src="/plugins/jquery/jquery-1.10.2.min.js"></script>
<script  src="/layui/layui.js"></script>
<script src="/plugins/js/common.js"></script>
<form class="layui-form" action="/healthInfo/updateHealthInfo" id="saveForm">
	<input type="hidden" name="id" th:value="${healthInfo.id}">
	<br>
<!--   <input type="hidden" id="attachmentId" name="attachmentId">	 -->
  <div class="layui-form-item">
	    <div class="layui-inline">
	      <label class="layui-form-label">资讯标题：</label>
	      <div class="layui-input-inline">
	        <input  name="title" placeholder="请输入产资讯标题" lay-verify="required" th:value="${healthInfo.title}"  style="width: 260px;" autocomplete="off" class="layui-input">
	      </div>
	    </div>
  </div>
   <div class="layui-form-item">
	    <div class="layui-inline">
	      <label class="layui-form-label">资讯内容：</label>
	      <div class="layui-input-block">
	       <textarea id="content"  style="display: none;" th:text="${healthInfo.content}"></textarea>
	      </div>
	    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">是否发布：</label>
     <div class="layui-input-block">
      <input type="radio" name="status"  lay-verify="required" value="1" th:checked="${healthInfo.status==1}" title="是">
      <input type="radio" name="status"  lay-verify="required" value="2"  th:checked="${healthInfo.status==2}" title="否">
    </div>
  </div>
<!--   <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;"> -->
<!--   <legend>请上传产品图片</legend> -->
<!-- </fieldset> -->
<!-- <div class="layui-upload"> -->
<!--   <button type="button" class="layui-btn" id="test1">上传图片</button> -->
<!--   <div class="layui-upload-list"> -->
<!--     <img class="layui-upload-img" id="demo1"> -->
<!--     <p id="demoText"></p> -->
<!--   </div> -->
<!-- </div>    -->
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit="" lay-filter="updateHealthInfo">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>
<script type="text/javascript">
layui.use(['form', 'layedit','upload'], function(){
	 upload = layui.upload;
	 form = layui.form;
	 var layedit = layui.layedit;
	 var contentIndex = layedit.build('content'); //建立编辑器
	 form.on('submit(updateHealthInfo)', function(data){
		 data.field.content=layedit.getContent(contentIndex);
		  $.ajax({
              url: "/healthInfo/updateHealthInfo",
              data: data.field,
              type: "post",
              success: function (result) {
            	if(result.status==1){
            		parent.search("修改成功");
                	var index = parent.layer.getFrameIndex(window.name);
                	setTimeout(function(){parent.layer.close(index)}, 1000);
            	}else{
            		layMsg("修改失败",2000);
            	}
              },
              error: function (result) {
            	  layMsg("请求异常",2000);
              }
		});
	return false;	  
	});
	 
	//普通图片上传
// 	  var uploadInst = upload.render({
// 	    elem: '#test1'
// 	    ,url: '/uploadImg'
// 	    ,before: function(obj){
// 	      //预读本地文件示例，不支持ie8
// 	      obj.preview(function(index, file, result){
// 	        $('#demo1').attr('src', result); //图片链接（base64）
// 	      });
// 	    }
// 	    ,done: function(res){
// 	      //如果上传失败
// 	      if(res.status == 2){
// 	        return layer.msg('上传失败');
// 	      }else{
// 	    	$("#attachmentId").val(res.data);
// 	    	return layer.msg('上传成功');
// 	      }
// 	      //上传成功
// 	    }
// 	    ,error: function(){
// 	      //演示失败状态，并实现重传
// 	      var demoText = $('#demoText');
// 	      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
// 	      demoText.find('.demo-reload').on('click', function(){
// 	        uploadInst.upload();
// 	      });
// 	    }
// 	  });
});


</script>
</body>
</html>